package Test;


import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import aop.ErrorLogger;
import service.UserService;

public class ErrorLoggerTest {

    @Test
    public void testAfterThrowing() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext3.xml");
        ErrorLogger errorLogger = context.getBean(ErrorLogger.class);
        UserService userService = context.getBean(UserService.class);

        try {
            // 模拟 UserService 中的方法抛出异常
            userService.save(null);
        } catch (RuntimeException e) {
            errorLogger.afterThrowing(null, e);
        }
    }
}
